package io.github.maojian.dynamicprogramming;

import org.junit.Test;

/**
 * @Auther: jian.mao
 * @Date: 2022-06-21 15:43
 * @Description: https://leetcode.cn/problems/n-th-tribonacci-number/
 */
public class Q1137 {
    public int tribonacci(int n) {
        int temp, f0 = 0, f1 = 1, f2 = 1;
        if (n == 0) return f0;
        if (n == 1) return f1;
        if (n == 2) return f2;
        for (int i = 3; i <= n; i++) {
            temp = f0 + f1 + f2;
            f0 = f1;
            f1 = f2;
            f2 = temp;
        }
        return f2;
    }

    @Test
    public void test(){
        System.out.println(tribonacci(25));
    }
}
